#pragma once
#include "Mutex.hpp"
#include <pthread.h>

namespace MyCond
{
    using namespace MpthreayMutex;
    class Cond
    {
    public:
        Cond()
        {
            int n = pthread_cond_init(&_cond, nullptr);
            (void)n;
        }
        void wait(Mutex& mtx)
        {
            int n = pthread_cond_wait(&_cond, mtx.LockPtr());
            (void)n;
        }
        void Notify() // 通知
        {
            int n = pthread_cond_signal(&_cond);
            (void)n;
        }
        void NotifyAll()
        {
            int n = pthread_cond_broadcast(&_cond);
            (void)n;
        }
        pthread_cond_t *Adrr()
        {
            return &_cond;
        }
        ~Cond()
        {
            int n = pthread_cond_destroy(&_cond);
            (void)n;
        }

    private:
        pthread_cond_t _cond;
    };
}